package com.xiaocg.base.juc;

import java.util.concurrent.CountDownLatch;

/**
 * @author xiaocg
 * 计数器
 */
public class CountDownLatchDemo {

    public static void main(String[] args) throws Exception{
        CountDownLatch countDownLatch = new CountDownLatch(5);

        for (int i = 0; i < 5; i++) {
            new Thread(()->{
                System.out.println("当前线程:"+Thread.currentThread().getName());
                countDownLatch.countDown();
            }).start();
        }

        countDownLatch.await();
        System.out.println("主线程:"+Thread.currentThread().getName());
    }
}
